<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>SetGadgetItemData</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<font face="Verdana, sans-serif" size="2"><p align="center"><b><font size="4">SetGadgetItemData()</font></b></p>
<p><b>语法</b></p><blockquote>
<font color="#3A3966"><b>SetGadgetItemData</b></font>(#Gadget, Item, Value)</blockquote>

</blockquote>
<b>概要</b><br><blockquote>



Stores the given value with the specified gadget item. This value can later be read with the <a href="getgadgetitemdata.html">GetGadgetItemData()</a> 
function. This allows to associate a custom value with the items of a gadget. 

 

</blockquote><p><b>参数</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Gadget</i></td>
<td width="90%"> 
 
The gadget to use. 

 

</td></tr>
<tr><td><i>Item</i></td>
<td> 
 
The item to use. The first item in the gadget has index 0. 

 

</td></tr>
<tr><td><i>Value</i></td>
<td> 
 
The value to set. 

 

</td></tr>
</table>
</blockquote><p><b>返回值</b></p><blockquote>
无.


</blockquote><p><b>备注</b></p><blockquote>



The set value will remain with the item, even 
if the item changes its index (for example because other items were deleted). 
<br>
<br>
This function works with the following gadgets: 
<br>
- <a href="comboboxgadget.html">ComboBoxGadget()</a> 
<br>
- <a href="listicongadget.html">ListIconGadget()</a> 
<br>
- <a href="listviewgadget.html">ListViewGadget()</a> 
<br>
- <a href="panelgadget.html">PanelGadget()</a> 
<br>
- <a href="treegadget.html">TreeGadget()</a> 


</blockquote><p><b>示例</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#3A3966">; This code uses SetGadgetItemData to store the original position</font>
  <font color="#3A3966">; of each item to later know it, even if the items index changed.</font>
  <font color="#3A3966">;</font>
  <b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenWindow</font>(0, 0, 0, 280, 250, "SetGadgetItemData", <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font>)
<font color="#3A3966">    ButtonGadget</font>(0,  10, 10, 80, 20, "Add")
<font color="#3A3966">    ButtonGadget</font>(1, 100, 10, 80, 20, "Remove")
<font color="#3A3966">    ButtonGadget</font>(2, 190, 10, 80, 20, "Test")
<font color="#3A3966">    ListViewGadget</font>(3, 10, 40, 260, 200)
    <b><font color="#3A3966">For</font></b> i = 0 <b><font color="#3A3966">To</font></b> 10
<font color="#3A3966">      AddGadgetItem</font>(3, i, "Old Item "+<font color="#3A3966">Str</font>(i))
<font color="#3A3966">      SetGadgetItemData</font>(3, i, i)
    <b><font color="#3A3966">Next</font></b> i

    <b><font color="#3A3966">Repeat</font></b>
      Event =<font color="#3A3966"> WaitWindowEvent</font>()
      <b><font color="#3A3966">If</font></b> Event = <font color="#924B72">#PB_Event_Gadget</font>
        item =<font color="#3A3966"> GetGadgetState</font>(3)

        <b><font color="#3A3966">Select</font></b> <font color="#3A3966">EventGadget</font>()
          <b><font color="#3A3966">Case</font></b> 0 <font color="#3A3966">; Add</font>
<font color="#3A3966">            AddGadgetItem</font>(3, item, "New Item")
            <b><font color="#3A3966">If</font></b> item &lt;&gt; -1
<font color="#3A3966">              SetGadgetItemData</font>(3, item, -1)
            <b><font color="#3A3966">Else</font></b>
<font color="#3A3966">              SetGadgetItemData</font>(3,<font color="#3A3966"> CountGadgetItems</font>(3)-1, -1)
            <b><font color="#3A3966">EndIf</font></b>

          <b><font color="#3A3966">Case</font></b> 1 <font color="#3A3966">; Remove</font>
            <b><font color="#3A3966">If</font></b> item &lt;&gt; -1
<font color="#3A3966">              RemoveGadgetItem</font>(3, item)
            <b><font color="#3A3966">EndIf</font></b>

          <b><font color="#3A3966">Case</font></b> 2 <font color="#3A3966">; Test</font>
            <b><font color="#3A3966">If</font></b> item &lt;&gt; -1
              value =<font color="#3A3966"> GetGadgetItemData</font>(3, item)
              <b><font color="#3A3966">If</font></b> value = -1
<font color="#3A3966">                MessageRequester</font>("", "Its a new item.")
              <b><font color="#3A3966">Else</font></b>
<font color="#3A3966">                MessageRequester</font>("", "It was item number "+<font color="#3A3966">Str</font>(value))
              <b><font color="#3A3966">EndIf</font></b>
            <b><font color="#3A3966">EndIf</font></b>

        <b><font color="#3A3966">EndSelect</font></b>
      <b><font color="#3A3966">EndIf</font></b>
    <b><font color="#3A3966">Until</font></b> Event = <font color="#924B72">#PB_Event_CloseWindow</font>
  <b><font color="#3A3966">EndIf</font></b>
</font></pre>

</blockquote><p><b>参阅</b></p><blockquote>

<a href="getgadgetitemdata.html">GetGadgetItemData()</a>, <a href="getgadgetdata.html">GetGadgetData()</a>, <a href="setgadgetdata.html">SetGadgetData()</a> 

</Blockquote><p><b>已支持操作系统 </b><Blockquote>所有</Blockquote></p><center>&lt;- <a href=setgadgetitemcolor.html>SetGadgetItemColor()</a> - <a href="index.html">Gadget Index</a> - <a href="setgadgetitemimage.html">SetGadgetItemImage()</a> -&gt;<br><br>

</body></html>